<template>
  <div class="custom-service_mod" :class="themeClass">
    <v-loading v-if="loading" />
    <v-nav v-if="isDayTime === false" title_color="#fff" :title="$t('Customerservice.Customer Service Center')" :class="themeClass"></v-nav>
    <v-nav v-if="isDayTime === true" :title="$t('Customerservice.Customer Service Center')"></v-nav>
    <div class="custom-service_mod_box">
      <div class="img">
        <img src="@/assets/img/service@2x.png" alt="" />
        <div>
          <h1>{{ $t('Customerservice.Customer Service Center') }}</h1>
          <p>{{ $t('Customerservice.Serve you warmly anytime, anywhere') }}</p>
        </div>
      </div>
      <div class="main">
        <div class="btn" v-for="(item, index) in serviceList" :key="index">
          <van-button round block type="info" color="#DAAB51" @click="serviceClick(item)">
            <img src="@/assets/img/Headset24x24@2x.png" alt="" />
            <span>{{ item.title }}</span>
          </van-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'CustomerService',
  data() {
    return {
      serviceList: [
        { title: this.$t('Customerservice.Online Service'), url: '' },
        { title: this.$t('Customerservice.Loan customer service'), url: '' }
      ],
      isDayTime: false,
      loading: false
    }
  },
  computed: {
    themeClass() {
      return this.isDayTime ? '' : 'darknight'
    },
    bgColor() {
      return this.isDayTime ? 'black' : 'white'
    },
    themeClass1() {
      return this.isDayTime ? '' : 'dark_li_color'
    }
  },
  watch: {
    '$store.state.nightMode': {
      handler(newVal) {
        this.isDayTime = newVal
      },
      immediate: true
    }
  },
  created() {
    this.getCustomer()
  },
  methods: {
    async getCustomer() {
      this.loading = true
      await this.$https.post('/Platform/getCustomerService').then(res => {
        if (res != undefined && res.code == 1) {
          this.serviceList[0].url = res.data.online_service
          this.serviceList[1].url = res.data.loan_customer_service
        }
      })
      this.loading = false
    },
    serviceClick(item) {
      window.open(item.url, '_self')
    }
  }
}
</script>

<style lang="less" scoped>
@import url('./index.less');
</style>
